import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/common/config.dart';
import 'package:finance_app/src/entities/format/service_and_product_entity.dart';
import 'package:finance_app/src/widgets/select/mixin/check_box_mixin.dart';
import 'package:finance_app/src/widgets/select/mixin/radio_mixin.dart';
import 'package:flutter/material.dart';

class SelectItemCheckBox = SelectItemRadio with CheckBoxMixin;

class SelectItemRadio extends StatelessWidget with RadioMixin {
  final bool isSelect;
  final ServiceAndProductEntity item;
  final EdgeInsets padding;
  final double minWidth;
  final bool isActivated;
  final bool isSelectMode;

  const SelectItemRadio({
    Key key,
    this.isSelect = false,
    @required this.item,
    this.padding = const EdgeInsets.all(8.0),
    this.isSelectMode,
    this.isActivated,
    this.minWidth,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    TextStyle style = TextStyle(
      color: aceBlueColor,
      fontSize: getSp(14),
      fontWeight: FontWeight.w400,
      height: 1,
    );
    TextStyle boldStyle = TextStyle(
      color: aceBlueColor,
      fontSize: getSp(16),
      fontWeight: FontWeight.w700,
      height: 1,
    );

    return Column(
      children: [
        Padding(
          padding: padding,
          child: Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              if (isSelectMode == true) ...[
                buildSelectWidget,
                SizedBox(
                  width: getDp(24),
                ),
              ],
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Text(
                      item.name,
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      style: boldStyle,
                    ),
                    if (Config.currentCompany.enableGst == 1)
                      Column(
                        children: [
                          SizedBox(
                            height: getDp(6),
                          ),
                          Text(
                            '${item.tax.rate}% ${item.tax.name}',
                            style: style,
                          )
                        ],
                      ),
                  ],
                ),
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Text(
                    item.totalAmount.toStringAsFixed(2),
                    style: boldStyle,
                  ),
                  SizedBox(
                    height: getDp(6),
                  ),
                  Text(
                    '${item.number} x ${item.price.toStringAsNotFixed(2)}',
                    style: style,
                  )
                ],
              ),
            ],
          ),
        ),
        AppSpaces.grayH05,
      ],
    );
  }
}
